package com.xiaohai.exception;

import com.xiaohai.common.R;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.sql.SQLException;

/**
 * ClassName:GloableException
 * Package:IntelliJ IDEA
 * Description:
 * Author 何诗海
 *
 * @Create 2023/8/18 17:31
 * @Version 1.0
 */
@RestControllerAdvice
public class GlobalException {
    @ExceptionHandler(CustomException.class)
    public R<String> CustomException(Exception e) {
        return R.error(e.getMessage(),401);
    }
    @ExceptionHandler(SQLException.class)
    public R<Object> SqlException(SQLException e) {
        return R.error("sql语句异常", 201);
    }

//    @ExceptionHandler(Exception.class)
//    public R<Object> globalException(Exception e) {
//        return R.error("服务器内部错误", 201);
//    }



}
